import {getWebSocketInfo} from '@/api/manager.js';
import { getAuth } from '@/utils/auth';

const state = {
    token: getAuth('T'),
    websocket: {
        riskTotal:0,
        riskWarNum:0,
        repDowNum:0,
    },
}

const mutations = {
    SET_WEBSOCKET: (state, dataList) => {
        state.websocket = {
            riskTotal:dataList[0].riskTotal,
            riskWarNum:dataList[0].riskWarNum,
            repDowNum:dataList[0].repDowNum
        };
    },
}

const actions = {
    getWebSocketDataList(){
        getWebSocketInfo().then( res =>{
            console.log(res);
        })
    },
    websocketonmessage({ commit, state },dataList){
        commit('SET_WEBSOCKET',dataList)
    },
}

export default {
    state,
    mutations,
    actions
}
